package test5.editor;

import javax.swing.text.Segment;

/**
 * Created by Claudiu-Florin FILIMON
 * Date: Aug 4, 2007
 * Time: 1:13:11 PM
 * Revision: 0
 */
public class JavaKeywords
{
    public final static String keywords[] = {
            "abstract",
            "boolean", "break", "byte",
            "case", "catch", "char", "class", "const", "continue",
            "default", "do", "double",
            "else", "extends",
            "final", "finally", "float", "for", "false",
            "goto",
            "if", "implements", "import", "instanceof", "int", "interface",
            "long",
            "native", "new",
            "package", "private", "protected", "public",
            "return", "short", "static", "strictfp", "super", "switch", "synchronized",
            "this", "throw", "throws", "transient", "try", "true",
            "void", "volatile",
            "while"
    };

    public JavaKeywords()
    {
    }

    public static boolean isKeyword(Segment seg)
    {
        boolean match = false;

        for (int i = 0; match == false && i < keywords.length; i++)
        {
            if (seg.count == keywords[i].length())
            {
                match = true;
                for (int j = 0; match == true && j < seg.count; j++)
                {
                    if (seg.array[seg.offset + j] != keywords[i].charAt(j))
                    {
                        match = false;
                    }
                }
            }
        }
        return match;
    }
}
